package com.dede.rxbase.comm;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.View;

import com.dede.rxbase.util.BLog;

/**
 * @author hsh
 *         2018/1/22 14:15.
 */
public class FragmentLifecycle extends FragmentManager.FragmentLifecycleCallbacks {

    private FragmentLifecycle() {
    }

    private static FragmentLifecycle mInstance;

    /**
     * 在Activity内注册的FragmentLifecycleCallback，所以使用单例模式
     *
     * @return
     * @see com.dede.rxbase.activity.BaseActivity#onCreate(Bundle)
     */
    public static FragmentLifecycle getInstance() {
        if (mInstance == null) {
            mInstance = new FragmentLifecycle();
        }
        return mInstance;
    }

    @Override
    public void onFragmentPreAttached(FragmentManager fm, Fragment f, Context context) {
    }

    @Override
    public void onFragmentAttached(FragmentManager fm, Fragment f, Context context) {
    }

    @Override
    public void onFragmentPreCreated(FragmentManager fm, Fragment f, Bundle savedInstanceState) {
    }

    @Override
    public void onFragmentCreated(FragmentManager fm, Fragment f, Bundle savedInstanceState) {
        BLog.log(f, "onFragmentCreated");
    }

    @Override
    public void onFragmentActivityCreated(FragmentManager fm, Fragment f, Bundle savedInstanceState) {
    }

    @Override
    public void onFragmentViewCreated(FragmentManager fm, Fragment f, View v, Bundle savedInstanceState) {
        BLog.log(f, "onFragmentViewCreated");
    }

    @Override
    public void onFragmentStarted(FragmentManager fm, Fragment f) {
        BLog.log(f, "onFragmentStarted");
    }

    @Override
    public void onFragmentResumed(FragmentManager fm, Fragment f) {
    }

    @Override
    public void onFragmentPaused(FragmentManager fm, Fragment f) {
    }

    @Override
    public void onFragmentStopped(FragmentManager fm, Fragment f) {
        BLog.log(f, "onFragmentStopped");
    }

    @Override
    public void onFragmentSaveInstanceState(FragmentManager fm, Fragment f, Bundle outState) {
        BLog.log(f, "onFragmentSaveInstanceState");
    }

    @Override
    public void onFragmentViewDestroyed(FragmentManager fm, Fragment f) {
        BLog.log(f, "onFragmentViewDestroyed");
    }

    @Override
    public void onFragmentDestroyed(FragmentManager fm, Fragment f) {
        BLog.log(f, "onFragmentDestroyed");
    }

    @Override
    public void onFragmentDetached(FragmentManager fm, Fragment f) {
    }
}
